-- UIRevengeUserInfo
-- Create By zouyb May/12/2016
-- 复仇信息界面

-- UIRevengeUserInfo继承自Layer
UIRevengeUserInfo = class("UIRevengeUserInfo", function()
    return cc.Layer:create();
end);

function UIRevengeUserInfo.create(info)
    return UIRevengeUserInfo.new(info);
end

-- 内部函数声明
local offsetY = 0;

-- 奖励格最大行数和列数
local MAX_GRID_ROW    = 2;
local MIN_GRID_COLUMN = 4;
local SCRAP_CLASS_ID  = 10000;

-- 构造函数
function UIRevengeUserInfo:ctor(info)
    -- 初始化
    self:setName("UIRevengeUserInfo");
    -- 复用飞艇信息页面
    local node = cc.CSLoader:createNode("layout/sky_city/IslandInfo.csb");
    self:addChild(node);
    self.node = node;

    -- 传递的信息
    self.info = info;

    self:getDetailInfo();

    local bonusNode = findChildByName(self.node, "BT2/desc_node/bonus_node");
    self.scrollView = findChildByName(bonusNode, "bonus_panel");

    -- 注册事件处理回调函数
    self:registerEventCallback();

    local titleLabel = findChildByName(self.node, "Top/title/text");
    self.titleLabelX = titleLabel:getPositionX();

    -- 重绘
    self:redraw();

    -- 播放信息出现效果
    local detailNode = findChildByName(self.node, "CT/detail_node");
    playAirShipInfoEffect(detailNode);

    -- 播放准心特效
    -- local reticleNode = findChildByName(self.node, "CT/reticle_node");
    playReticleEffect(self.node);

    -- 注册点击事件
    self:registerTouchEvent();

    -- 标题和描述在中间浮现
    self:comformCenterEffect();

    -- 适配
    self:resize();
end

-- 初始化奖励格子
function UIRevengeUserInfo:initGrids(totalGridCount)
    local w = DESIGN_WIDTH;
    local h = DESIGN_HEIGHT;

    -- 图标间距(横向)
    local wGap = -5;

    -- 图标间距(纵向)
    local hGap = 10;

    -- 图标宽度
    local iconWidth = 127;

    -- 图片高度
    local iconHeight = 110;

    local topHGap  = 10;
    local bottomHGap  = 0;
    local leftWGap = 5;

    -- 总数
    local totalCount = totalGridCount;

    self.scrollView.rows = {};
    self.scrollView:removeAllChildren();

    local itemNode = cc.CSLoader:createNode("layout/sky_city/SkyStoreItem.csb");
    -- @param windowNode    界面节点
    -- @param scrollNode    容器节点
    -- @param itemNode      单元格的节点
    -- @param totalNum      单元格总数
    -- @param maxRowNum     最大行数
    -- @param pageColNum    单页可以显示下的列数
    -- @param wGap          单元格间距(横向) 这里作为最小值使用
    -- @param hGap          单元格间距(纵向)
    -- @param iconWidth     单元格宽度
    -- @param iconHeight    单元格高度
    -- @param topHGap       上方留白
    -- @param leftWGap      左右留白  这里作为最小值使用
    -- @param touchEvent    点击事件注册函数
    -- @param initHandle    格子初始化委托
    -- @param schedulerId   定时器id
    initScrollGridsVertical(self, self.scrollView, itemNode,
        totalCount, MAX_GRID_ROW, MIN_GRID_COLUMN, wGap, hGap,
        iconWidth, iconHeight, topHGap, bottomHGap, leftWGap);

    for _, child in ipairs(self.scrollView.rows) do
        child:setScale(0.88);
    end
end

-- 清空所有的奖励格
function UIRevengeUserInfo:clearAllGrid()
    self.scrollView.rows = {};
    self.scrollView:removeAllChildren();
end

-- 重绘奖励
function UIRevengeUserInfo:redrawBonus()
    -- 收集信息
    local goodsList = self.data["bonus"] or {};
    local totalGridCount = #goodsList;

    if not goodsList or #goodsList == 0 then
        cclog("收集信息失败。");
        self:clearAllGrid();
        return;
    end

    if totalGridCount < 4 then
        totalGridCount = 4;
    end

    -- 初始化格子
    self:initGrids(totalGridCount);

    -- 显示奖励信息
    local totalGoodsCount = #goodsList;
    for i = 1, totalGridCount do
        local grid          = self.scrollView:getChildByName("item" .. i);
        local goodsBg       = grid:getChildByName("bg");
        local buyImg        = grid:getChildByName("buy");
        local starNode      = grid:getChildByName("stars");
        local numLabel      = grid:getChildByName("num_label");
        local countLabel    = grid:getChildByName("num");
        local iconImg       = grid:getChildByName("icon");

        countLabel:setVisible(true);
        numLabel:setVisible(false);
        buyImg:setVisible(false);

        if i <= totalGoodsCount and type(goodsList[i]) == "table" then
            grid:setVisible(true);

            local classId = goodsList[i][2];
            local count   = goodsList[i][3];

            -- 显示数量
            TextStyleM.setTextStyle(countLabel, TextStyleM.TEXT_SIZE_SMALL2, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true, -2);
            if count > 1 then
                -- 需要显示数量
                countLabel:setString(changeNumType(count));
            else
                countLabel:setVisible(false);
            end

            -- 显示商品图标
            local goodsIcon;
            local para;
            if goodsList[i][1] == 1 then
                goodsIcon = getItemIconPath(ItemM.query(classId, "icon"));
                if classId == 10000 then
                    para = {["detail"] = getLocStr("revenge_relic_detail"), }
                end
            elseif goodsList[i][1] == 2 then
                if classId == "money" and i == 2 then
                    -- 金币
                    goodsIcon = getRelicIcon("car_money");
                    local detail = getLocStr("revenge_money_detail");
                    para = {["detail"] = detail};
                else
                    goodsIcon = getLargeAttribIconPath(FieldsM.query(classId, "icon"));
                end
            elseif goodsList[i][1] == 6 then
                -- 秘宝
                goodsIcon = getAirShipSkillIconPath(SkyShipSkillM.query(classId, "icon"));
            elseif goodsList[i][1] == 8 then
                -- 机器人
                goodsIcon = getRobotIconPath(SkyRobotM.query(classId, "icon"));
            end

            iconImg:loadTexture(goodsIcon);

            -- 注册点击事件
            self:clickShowDesc(grid, goodsList[i], para);
        else
            -- 清空多余的格子设置为灰白
            iconImg:setVisible(false);
            setGrayTransMode(goodsBg, true);
        end
    end
end

-- 点击图标处理
function UIRevengeUserInfo:clickShowDesc(node, bonus, para)
    -- 点击处理
    local bg = findChildByName(node, "bg");
    bg:setTouchEnabled(true);
    bg:addTouchEventListener(function(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            AudioM.playFx("workshop_material");
            -- 显示道具详细信息
            if bonus[1] == 1 then
                -- 物品
                UIMgr:getCurrentScene():removeFormByName("UIItemDesc");
                local uiItemDesc = UIItemDesc.create(bonus[2], nil, para);
                UIMgr:getCurrentScene():addForm(uiItemDesc);
            elseif bonus[1] == 2 and bonus[2] == "money" then
                -- TODO属性，暂时使用物品的，到时候需要和属性描述一起处理
                UIMgr:getCurrentScene():removeFormByName("UIItemDesc");
                local uiItemDesc = UIItemDesc.create(bonus[2], nil, para);
                UIMgr:getCurrentScene():addForm(uiItemDesc);
            elseif bonus[1] == 3 then
                -- 英雄
                UIMgr.getCurrentScene():removeFormByName("UIHeroDetailInfo");
                local uiHeroInfo = UIHeroDetailInfo.create(bonus[2]);
                UIMgr.getCurrentScene():addForm(uiHeroInfo);
            elseif bonus[1] == 6 then
                -- 秘宝
                UIMgr.getCurrentScene():removeFormByName("UIAirShipSkillDesc");
                local uishipSkillForm = UIAirShipSkillDesc.create(bonus[2]);
                UIMgr:getCurrentScene():addForm(uishipSkillForm);
            elseif bonus[1] == 8 then
                -- 机器人
                UIMgr:getCurrentScene():removeFormByName("UISkyStoreItem");
                require "game/ui/form/sky_city/UISkyStoreItem";
                local uiStoreItem = UISkyStoreItem.create(bonus[2], "robot", {["robot_tip"] = true});
                UIMgr.getCurrentScene():addForm(uiStoreItem);
            end
        end
    end);
end

-- 获取信息
function UIRevengeUserInfo:getDetailInfo()
    -- 复仇玩家的信息
    self.data = table.deepcopy(self.info);

    local attribs = {"fire", "luck", "speed", "armor", "fight_ability"};

    local skyProp = self.data["sky_prop"] or {};
    for _, attrib in ipairs(attribs) do
        local addon = SkyPropM.calcAddonByData({["sky_prop"] = skyProp}, attrib, self.data[attrib]);
        self.data[attrib] = self.data[attrib] + addon;
    end

    local moneyNum = tonumber(self.info["money"]);
    local scrapNum = tonumber(self.info["scrap"]) + tonumber(self.info["ex_resource"]);

    -- 为了适配之前的结构，重组奖励信息
    self.data["bonus"] = { {1, 10000, scrapNum}, {2, "money", moneyNum}};
end

-- 重绘界面
function UIRevengeUserInfo:redraw()
    -- 重新获取信息
    self:getDetailInfo();

    local data = self.data;
    -- 显示标题
    local titleLabel = findChildByName(self.node, "Top/title/text");
    titleLabel:setString(getNickName(data.name));

    -- 玩家名字使用系统字
    titleLabel:setFontSize(TextStyleM.TEXT_SIZE_MIDDLE);
    titleLabel:setTextColor(TextStyleM.TEXT_COLOR_BROWN_YELLOW);

    -- 绘制图标
    local airShipNode = findChildByName(self.node, "CT/airship");
    airShipNode:stopAllActions();
    airShipNode:removeAllChildren();

    -- 飞艇
    createAirShip(airShipNode, data.ship_id);

    if type(NewAirShipM.query(data.ship_id, "fly_effect")) == "number" then
        airShipNode:setPositionX(airShipNode:getPositionX());
    end

    -- 飞艇悬浮
    playFluctuateAnima(airShipNode, 0.1, 1);

    -- 显示符石框
    local stoneNode = findChildByName(self.node, "BT2/stone");
    if not stoneNode.iconNode then
        local itemNode = cc.CSLoader:createNode("layout/sky_city/SkyCityStoneItem.csb");
        stoneNode.iconNode = findChildByName(itemNode, "icon");
        stoneNode.iconNode:setVisible(false);
        stoneNode.bgNode = findChildByName(itemNode, "bg");
        stoneNode.hintNode = findChildByName(itemNode, "hint");

        itemNode:setScale(0.8);

        stoneNode:removeAllChildren();
        stoneNode:addChild(itemNode);

        -- 显示泡泡
        stoneNode.hintNode:setVisible(true);
        playCanEquipHintEffect(stoneNode.hintNode, 0, 0);
    end

    local detailNode = findChildByName(self.node, "CT/detail_node");
    -- 火力
    local attribLabel = findChildByName(detailNode, "fire_node/attrib");
    local valueLabel = findChildByName(detailNode, "fire_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_fire"));
    valueLabel:setString(data.fire);

    -- 装甲
    attribLabel = findChildByName(detailNode, "armor_node/attrib");
    valueLabel = findChildByName(detailNode, "armor_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_armor"));
    valueLabel:setString(data.armor);

    -- 机动
    attribLabel = findChildByName(detailNode, "speed_node/attrib");
    valueLabel = findChildByName(detailNode, "speed_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_speed"));
    valueLabel:setString(data.speed);

    -- 幸运
    attribLabel = findChildByName(detailNode, "luck_node/attrib");
    valueLabel = findChildByName(detailNode, "luck_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("airship_luck"));
    valueLabel:setString(data.luck);

    -- 总战力
    attribLabel = findChildByName(detailNode, "ability_node/attrib");
    valueLabel = findChildByName(detailNode, "ability_node/value");

    self:setSystemTextStyle(attribLabel);
    self:setSystemTextStyle(valueLabel);

    attribLabel:setString(getLocStr("fight_ability_2"));
    -- 逗号分段战力
    valueLabel:setString(thousandNum(data.fight_ability));

    -- 显示阵营
    local slimeLabel = findChildByName(detailNode, "camp_node/attrib");
    local countLabel = findChildByName(detailNode, "camp_node/value");

    self:setSystemTextStyle(slimeLabel);
    self:setSystemTextStyle(countLabel);

    slimeLabel:setString(getLocStr("pets_camp"));
    local campId = CampM.getPetCamp(data.pets[1]);
    local campName = CampM.query(campId, "name");

    countLabel:setString(campName);

    -- 国籍
    local nation = findChildByName(self.node, "Top/title/nation");
    local nationId = data.nation or 0;
    -- 显示国籍
    local icon = TopM.queryNationality(nationId, "icon");
    nation:loadTexture(getNationalityIconPath(icon));
    nation:setVisible(true);

    -- 先调整下位置
    titleLabel:setPositionX(self.titleLabelX);

    -- 国籍位置自适应
    setNextNodePosX(titleLabel, nation, 10);

    -- 获取下国籍宽度
    local nationWidth = nation:getContentSize().width;
    titleLabel:setPositionX(titleLabel:getPositionX() + nationWidth / 2);
    nation:setPositionX(nation:getPositionX() + nationWidth / 2);

    self:redrawBonus();

    self:redrawDesc();

    self:redrawButton();
end

-- 更新符石图标
function UIRevengeUserInfo:updateStone(stoneClassId)
    self.stoneClassId = stoneClassId;

    local stoneNode = findChildByName(self.node, "BT2/stone");
    local iconName = ItemM.query(stoneClassId, "icon");
    stoneNode.iconNode:setVisible(true);
    stoneNode.iconNode:loadTexture(getItemIconPath(iconName));

    stoneNode.hintNode:setVisible(false);
end

-- 注册事件处理回调函数
function UIRevengeUserInfo:registerEventCallback()
    -- 界面析构后，需要清理下
    self:registerScriptHandler(function(eventType)
        if eventType == "exit" then
            EventMgr.removeAll("UIRevengeUserInfo");
        elseif eventType == "enter" then
        end
    end);

    -- 注册获得焦点的回调
    EventMgr.register("UIRevengeUserInfo", event.FOCUS_CHANGED, function(para)
        if para["get"] == "UIRevengeUserInfo" then
            UIMgr:getCurrentScene().topMenu:show(TOPMENU_FRAME_AIRSHIP_SCORE, TOPMENU_FRAME_AIRSHIP_ATTRIB,  TOPMENU_FRAME_HEAD_AIRSHIP);
        elseif para["lose"] == "UIRevengeUserInfo" then

        end
    end);

    -- 注册天空之城战斗的回调
    EventMgr.register("UIRevengeUserInfo", event.START_SKY_BATTLE, function(para)
        -- 直接去掉界面
        UIMgr.getCurrentScene():removeFormByName("UIRevengeUserInfo");
    end);
end

-- 重新绘制按钮
function UIRevengeUserInfo:redrawButton()
    local info = self.data;
    local btnRevenge = findChildByName(self.node, "BT/btn_make");

    -- 停止回调
    btnRevenge:stopAllActions();

    -- 时间回调/重新获取时间
    local robWaitTime = FormulaM.invoke("CALC_ROB_FAIL_WAIT_TIME", tonumber(info["fail_times"]));

    local function tick()
        -- 上次掠夺时间
        local lastTime = info["lastRevengeTime"] or 0;
        local leftTime = lastTime + robWaitTime - TimeM.getServerTime();

        if leftTime > 0 then
            -- 显示剩余时间
            btnRevenge:setTitleText(remainingTimeDesc(leftTime));
            performWithDelay(btnRevenge, tick, 1);
        else
            -- 直接显示按钮
            btnRevenge:setTitleText(getLocStr("btn_text_revenge"));
        end
    end
    tick();
end

-- 立即复仇
function UIRevengeUserInfo:showRevengeTip()
    local info = self.info;
    local cost = FormulaM.invoke("CALC_NO_WAIT_TO_ROB_COST");

    -- 确认函数
    local function okFun()
        if ME.user.dbase:query(cost[2], 0) < cost[3] then
            -- 弹出购买钻石提示
            showGemLackConfirm();
            return;
        else
            if not SkyRelicM.isValidRecord(info["record_rid"]) then
                -- 记录已经失效
                alert(getLocStr("revenge_record_unvalid"));
                self:redraw();
                return;
            end
            SkyRelicM.revenge(info["record_rid"], 1, self.stoneClassId or 0);
        end
    end

    local robWaitTime = FormulaM.invoke("CALC_ROB_FAIL_WAIT_TIME", tonumber(info["fail_times"]));
    local lastTime = info["lastRevengeTime"];
    local finalTime = lastTime + robWaitTime;
    local leftTime = finalTime - TimeM.getServerTime();
    local desc = string.format(getLocStr("last_revenge_fail_tip"), remainingTimeDesc(leftTime));

    -- 弹出离开迷宫确认提示框
    confirm2(CONFIRM_TYPE_OK_CANCEL, getLocStr("revenge_tip_title"), desc,
         okFun, nil, getLocStr("btn_text_revenge_now"), getLocStr("btn_text_cancel"),
         { ["cancelColor"] = "blue", ["leftTimeDesc"] = {"revenge", finalTime} });
end

-- 注册点击事件
function UIRevengeUserInfo:registerTouchEvent()
    -- 注册返回按钮点击事件
    local btnBack = findChildByName(self.node, "BT/btn_back");
    local function onBackClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            -- 关闭当前界面
            AudioM.playFx("ship_return");
            UIMgr.getCurrentScene():removeFormByName("UIRevengeUserInfo");
        end
    end
    AddBackEventHandler(self, btnBack, onBackClick);
    TextStyleM.setTextStyle(btnBack, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true);
    btnBack:setTitleText(getLocStr("btn_text_back"));

    -- 注册掠夺按钮
    local btnAttack = findChildByName(self.node, "BT/btn_make");
    TextStyleM.setTextStyle(btnAttack, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_BROWN_YELLOW, true);
    -- 按钮文字在redrawButton中处理SLIMEC-4250
    -- btnAttack:setTitleText(getLocStr("btn_text_revenge"));
    local function onRevengeClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            AudioM.playFx("button_click");
            local info = self.info;
            if SkyRelicM.isInCoolTime(info, "revenge") then
                -- 提示
                self:showRevengeTip();
            else
                if not SkyRelicM.isValidRecord(info["record_rid"]) then
                    -- 记录已经失效
                    alert(getLocStr("revenge_record_unvalid"));
                    self:redraw();
                    return;
                end
                -- 直接发起复仇
                SkyRelicM.revenge(info["record_rid"], 0, self.stoneClassId or 0);
            end
        end
    end
    btnAttack:addTouchEventListener(onRevengeClick);

    -- 注册替换按钮
    local btnActived = findChildByName(self.node, "BT/btn_actived");
    btnActived:setVisible(false);

    -- 隐藏翻页按钮
    local btnNext = findChildByName(self.node, "CT/btn_next");
    local btnLast = findChildByName(self.node, "CT/btn_last");
    local hideNodes = {btnNext, btnLast};
    for _, node in pairs(hideNodes) do
        node:setVisible(false);
    end

    -- 符石框点击处理
    local stoneNode = findChildByName(self.node, "BT2/stone");
    stoneNode.bgNode:setTouchEnabled(true);
    local function onStoneImgClick(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            -- 打开符石选择框
            require "game/ui/form/sky_city/UISkyStoneChoose";
            UIMgr.getCurrentScene():removeFormByName("UISkyStoneChoose");
            local uiForm = UISkyStoneChoose.create("revenge", self);
            UIMgr.getCurrentScene():addForm(uiForm);
        end
    end
    stoneNode.bgNode:addTouchEventListener(onStoneImgClick);

    -- -- 身上没有符石的话需要显示加号
    -- local hasStone = SkyStoneM.hasStone("plunder");
    -- if hasStone then
    --     stoneNode.hintNode:setVisible(false);
    -- else
    --     stoneNode.hintNode:setVisible(true);
    --     playCanEquipHintEffect(stoneNode.hintNode, 0, 0);
    -- end
end

-- 适配
function UIRevengeUserInfo:resize()
    local node = self.node;

    -- bg居中显示并充满整个屏幕
    AlignM.fitToScreen(node, "bg");
    AlignM.fitToScreen(node, "bg2");

    -- CT居中并缩放至合适大小
    AlignM.alignToCenter(node, "CT");

     AlignM.alignToTopCenter(node, "Top");

    -- BT置于底部并缩放至合适大小
    AlignM.alignToBottomCenter(node, "BT");
    AlignM.alignToBottomCenter(node, "BT2");
end

-- 设置信息的字体
function UIRevengeUserInfo:setSystemTextStyle(textLabel)
    textLabel:setFontSize(TextStyleM.TEXT_SIZE_TINY);
    textLabel:setTextColor(TextStyleM.TEXT_COLOR_BRIGHT_BLUE);
    TextStyleM.setOutlineStyle(textLabel, 2, TextStyleM.TEXT_COLOR_DARK_BLUE2, true);
end

-- 根据当前抽取到的类型，重绘描述信息
function UIRevengeUserInfo:redrawDesc()
    local descNode = findChildByName(self.node, "BT2/desc_node");
    local titleLabel = findChildByName(descNode, "title_label");
    local descLabel = findChildByName(descNode, "desc_label");

    -- 标题为飞艇名称
    local titleName = NewAirShipM.query(self.data.ship_id, "name");
    -- 掠夺描述
    local descStr = getLocStr("revenge_airship_desc");

    local lineCount = 4;
    local countPerLine = TextStyleM.TEXT_WORD_COUNT_PER_LINE;
    local fontSize = TextStyleM.TEXT_SIZE_SMALL;
    if isFullWidthLang() then
        lineCount = 3;
    elseif getLang() == "th" then
        lineCount = 1.4;
        fontSize = TextStyleM.TEXT_SIZE_MINI;
    else
        countPerLine = 24;
    end

    if getLang() == "ja" or getLang() == "ko" then
        fontSize = TextStyleM.TEXT_SIZE_SMALL2;
        countPerLine = 24;
    end
    local textScale = TextStyleM.getTextScale(descStr, countPerLine * 2 * lineCount);
    TextStyleM.setTextStyle(titleLabel, TextStyleM.TEXT_SIZE_MIDDLE, TextStyleM.TEXT_COLOR_DARK_RED);
    TextStyleM.setTextStyle(descLabel, fontSize, TextStyleM.TEXT_COLOR_DARK_BROWN, nil, nil, nil, nil, countPerLine, nil, nil, textScale);

    titleLabel:setString(titleName);
    descLabel:setString(descStr);

    local titlePosX = titleLabel:getPositionX();
    local labelWidth = titleLabel:getContentSize().width;

    local timeLPosx = titlePosX + labelWidth + 20;
    -- 绘制复仇有效时间
    self:redrawRevengeTime(timeLPosx);
end

-- 绘制复仇剩余时间
function UIRevengeUserInfo:redrawRevengeTime(timeLPosx)
    local subheadLabel = findChildByName(self.node, "BT2/desc_node/time_label");
    local kerning = -3;
    if not isFullWidthLang() then
        kerning = -1;
    end
    TextStyleM.setTextStyle(subheadLabel, TextStyleM.TEXT_SIZE_SMALL,
        TextStyleM.TEXT_COLOR_GRAY, false, getLocKerning() + kerning);

    subheadLabel:setPositionX(timeLPosx);

    subheadLabel:stopAllActions();

    subheadLabel:setVisible(true);


    local function tick()
        local robWaitTime = FormulaM.invoke("CALC_ROB_FAIL_WAIT_TIME", tonumber(self.info["fail_times"]));
        local leftTime = SkyRelicM.getVaildLeftTime(self.info["record_rid"]);

        if leftTime <= 0 then
            -- 关闭自身界面
            UIMgr.getCurrentScene():removeFormByName("UIRevengeUserInfo");
            return;
        end

        subheadLabel:setString(remainingTimeDesc3(leftTime, "disappear"));
        performWithDelay(subheadLabel, tick, 1);
    end
    tick();
end


-- 从中间浮现效果
function UIRevengeUserInfo:comformCenterEffect()
    local TOP = findChildByName(self.node, "Top");
    local BT2  = findChildByName(self.node, "BT2");
    if not TOP then
        return;
    end

    local titleNode = findChildByName(TOP, "title");
    local descNode = findChildByName(BT2, "desc_node");

    local oldScale = titleNode:getScale();
    local descSale = descNode:getScale();

    -- title
    titleNode:setScale(oldScale * 0.8);
    local scaleUp1 = cc.EaseIn:create(cc.ScaleTo:create(0.2, oldScale * 1.05), 0.4);
    local scaleUp2 = cc.ScaleTo:create(0.05, oldScale);
    titleNode:runAction(cc.Sequence:create(scaleUp1, scaleUp2));

    descNode:setScale(descSale * 0.8);
    local scaleUp3 = cc.EaseIn:create(cc.ScaleTo:create(0.2, descSale * 1.05), 0.4);
    local scaleUp4 = cc.ScaleTo:create(0.05, descSale);
    descNode:runAction(cc.Sequence:create(scaleUp3, scaleUp4));
end
